<!DOCTYPE html>
<html xmlns:th="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>Java 兴趣社后台管理</title>
    <meta name="description" content="">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <meta name="robots" content="all,follow">
    <link href="https://cdn.bootcss.com/twitter-bootstrap/4.4.1/css/bootstrap.css" rel="stylesheet">
    <link rel="stylesheet" href="/css/login/style.default.css" id="theme-stylesheet">
</head>
<body>
<div class="page login-page">
    <div class="container d-flex align-items-center">
        <div class="form-holder has-shadow">
            <div class="row">
                <!-- Logo & Information Panel-->
                <div class="col-lg-6">
                    <div class="info d-flex align-items-center">
                        <div class="content">
                            <div class="logo">
                                <h1>欢迎登录</h1>
                            </div>
                            <p>JAVA兴趣社管理后台</p>
                        </div>
                    </div>
                </div>
                <!-- Form Panel    -->
                <div class="col-lg-6 bg-white">
                    <div class="form d-flex align-items-center">
                        <div class="content">
                            <form method="post" action="/back/login" class="form-validate" id="loginFrom">
                                <h4 th:text="${msg}"></h4>
                                <div class="form-group">
                                    <input id="login-username" type="text" name="username" required data-msg="请输入用户名"
                                           placeholder="用户名" class="input-material">
                                </div>
                                <div class="form-group">
                                    <input id="login-password" type="password" name="password" required data-msg="请输入密码"
                                           placeholder="密码" class="input-material">
                                </div>
                                <button id="login" type="submit" class="btn btn-primary">登录</button>
                                <div style="margin-top: -40px;">
                                    <div class="custom-control custom-checkbox " style="float: right;">
                                        <input type="checkbox" class="custom-control-input" id="check2">
                                        <label class="custom-control-label" for="check2">自动登录</label>
                                    </div>
                                    <div class="custom-control custom-checkbox " style="float: right;">
                                        <input type="checkbox" class="custom-control-input" id="check1">
                                        <label class="custom-control-label" for="check1">记住密码&nbsp;&nbsp;</label>
                                    </div>
                                </div>
                            </form>
                            <br/>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<!-- JavaScript files-->
<script src="https://cdn.bootcss.com/jquery/3.4.1/jquery.js"></script>
<script src="https://cdn.bootcss.com/twitter-bootstrap/4.4.1/js/bootstrap.js"></script>
<script src="https://cdn.bootcss.com/jquery-cookie/1.4.1/jquery.cookie.js"></script>
<script src="https://cdn.bootcdn.net/ajax/libs/jquery-validate/1.19.2/jquery.validate.min.js"></script>
<!--<script src="/static/js/login/jquery.validate.min.js"></script>&lt;!&ndash;表单验证&ndash;&gt;-->
<!-- Main File-->
<script src="/js/login/front.js"></script>
<script>
    $(function () {
        /*判断上次是否勾选记住密码和自动登录*/
        let check1s = localStorage.getItem("check1");
        let check2s = localStorage.getItem("check2");
        let oldName = localStorage.getItem("userName");
        let oldPass = localStorage.getItem("passWord");
        if (check1s == "true") {
            $("#login-username").val(oldName);
            $("#login-password").val(oldPass);
            $("#check1").prop('checked', true);
        } else {
            $("#login-username").val('');
            $("#login-password").val('');
            $("#check1").prop('checked', false);
        }
        if (check2s == "true") {
            $("#check2").prop('checked', true);
            $("#loginFrom").submit();
        } else {
            $("#check2").prop('checked', false);
        }

        $("#login").click(function () {
            let userName = $("#login-username").val();
            let passWord = $("#login-password").val();
            /*获取当前输入的账号密码*/
            localStorage.setItem("userName", userName)
            localStorage.setItem("passWord", passWord)
            /*获取记住密码  自动登录的 checkbox的值*/
            let check1 = $("#check1").prop('checked');
            let check2 = $('#check2').prop('checked');
            localStorage.setItem("check1", check1);
            localStorage.setItem("check2", check2);
        })
    })
</script>
</body>
</html>